/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package za.co.pass.jtorrenteditor.list.model.data;

import java.util.List;
import za.co.pass.jtorrenteditor.helper.Utils;

/**
 *
 * @author alabuschagne
 */
public class AnnounceData
{
    private String url = "";
    private boolean ok = false;
    private int numberOfSeeds = 0;
    private boolean checked = false;
    private boolean busy = false;
    private String errorMsg = "";
    private String[] peers = null;

    public AnnounceData(List l)
    {
        if((l != null) && (l.size() > 0))
        {
            short[] s = (short[]) l.get(0);
            setUrl(new String(Utils.short2Char(s)));
        }
    }

    public AnnounceData(String url)
    {
        setUrl(url);
    }
    /**
     * @return the url
     */
    public String getUrl()
    {
        return url;
    }

    /**
     * @param url the url to set
     */
    public void setUrl(String url)
    {
        this.url = url;
    }

    /**
     * @return the ok
     */
    public boolean isOk()
    {
        return ok;
    }

    /**
     * @param ok the ok to set
     */
    public void setOk(boolean ok)
    {
        this.ok = ok;
    }

    /**
     * @return the numberOfSeeds
     */
    public int getNumberOfSeeds()
    {
        return numberOfSeeds;
    }

    /**
     * @param numberOfSeeds the numberOfSeeds to set
     */
    public void setNumberOfSeeds(int numberOfSeeds)
    {
        this.numberOfSeeds = numberOfSeeds;
    }

    /**
     * @return the checked
     */
    public boolean isChecked()
    {
        return checked;
    }

    /**
     * @param checked the checked to set
     */
    public void setChecked(boolean checked)
    {
        this.checked = checked;
    }

    /**
     * @return the busy
     */
    public boolean isBusy()
    {
        return busy;
    }

    /**
     * @param busy the busy to set
     */
    public void setBusy(boolean busy)
    {
        this.busy = busy;
    }

    public void setErrorMsg(String message)
    {
        errorMsg = message;
    }

    public String getErrorMsg()
    {
        return errorMsg;
    }

    public void setPeers(String[] peerIPPort)
    {
        peers = peerIPPort;
        if(peerIPPort == null)
        {
            setNumberOfSeeds(0);
        }
        else
        {
            System.out.println("PEERS IP:" + peerIPPort[0]);
            setNumberOfSeeds(peerIPPort.length);
        }
    }

    public String[] getPeers()
    {
        return peers;
    }
}
